﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace com.sharepointutils.application
{
    public class QueryValue
    {
        public String Type { get; set; }
        public String Value { get; set; }

        public override string ToString()
        {
            String xml = "<Value Type=\"" + this.Type + "\" >";
            xml += this.Value + "</Value>";
            return xml;
        }

        public QueryValue(String type, String value)
        {
            this.Value = value;
            this.Type = type;
        }

        public QueryValue(object value)
        {
            this.Value = value.ToString();
            this.Type = getType(value);
        }

        private String getType(object value)
        {
            String type;

            switch (value.GetType().Name)
            {
                case "String":
                case "string":
                    type = "Text";
                    break;
                default:
                    type = "Text";
                    break;
            }
            return type;

        }

    }
}
